using System;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections;
using BE;

namespace DAL//Duoc.BusinessLayer.DataLayer

{

	/// <summary>
	/// Data access layer class for Zd_BienBanKiemKe
	/// </summary>
	public class Zd_BienBanKiemKeSql : DataLayerBase 
	{

        #region Constructor

		/// <summary>
		/// Class constructor
		/// </summary>
		public Zd_BienBanKiemKeSql()
		{
			// Nothing for now.
		}

        #endregion

        #region Public Methods

        /// <summary>
        /// insert new row in the table
        /// </summary>
		/// <param name="businessObject">business object</param>
		/// <returns>true of successfully insert</returns>
		public bool Insert(Zd_BienBanKiemKe businessObject)
		{
			SqlCommand	sqlCommand = new SqlCommand();
			sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_Insert]";
			sqlCommand.CommandType = CommandType.StoredProcedure;

			// Use connection object of base class
			sqlCommand.Connection = MainConnection;

			try
			{
                
				sqlCommand.Parameters.Add(new SqlParameter("@KiemKe_ID", SqlDbType.Int, 4, ParameterDirection.Output, false, 0, 0, "", DataRowVersion.Proposed, businessObject.KiemKe_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@BoYTe", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.BoYTe));
				sqlCommand.Parameters.Add(new SqlParameter("@BenhVien", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.BenhVien));
				sqlCommand.Parameters.Add(new SqlParameter("@Khoa", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Khoa));
				sqlCommand.Parameters.Add(new SqlParameter("@MS", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.MS));
				sqlCommand.Parameters.Add(new SqlParameter("@So", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.So));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten1", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten1));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten2", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten2));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten3", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten3));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten4", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten4));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten5", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten5));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh1", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh1));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh2", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh2));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh3", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh3));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh4", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh4));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh5", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh5));
				sqlCommand.Parameters.Add(new SqlParameter("@Date1", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Date1));
				sqlCommand.Parameters.Add(new SqlParameter("@Date2", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Date2));
				sqlCommand.Parameters.Add(new SqlParameter("@ThoiGian", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ThoiGian));
				sqlCommand.Parameters.Add(new SqlParameter("@DeXuat", SqlDbType.NText, 1073741823, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DeXuat));
				sqlCommand.Parameters.Add(new SqlParameter("@ThanhVien", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ThanhVien));
				sqlCommand.Parameters.Add(new SqlParameter("@ThuKy", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ThuKy));
				sqlCommand.Parameters.Add(new SqlParameter("@ChuTich", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChuTich));
				sqlCommand.Parameters.Add(new SqlParameter("@TinhTrang", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TinhTrang));
				sqlCommand.Parameters.Add(new SqlParameter("@Field1", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field1));
				sqlCommand.Parameters.Add(new SqlParameter("@Field2", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field2));
				sqlCommand.Parameters.Add(new SqlParameter("@Field3", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field3));
				sqlCommand.Parameters.Add(new SqlParameter("@Field4", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field4));
				sqlCommand.Parameters.Add(new SqlParameter("@Field5", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field5));

								
				MainConnection.Open();
				
				sqlCommand.ExecuteNonQuery();
                businessObject.KiemKe_ID = (int)sqlCommand.Parameters["@KiemKe_ID"].Value;

				return true;
			}
			catch(Exception ex)
			{				
				throw new Exception("Zd_BienBanKiemKe::Insert::Error occured.", ex);
			}
			finally
			{			
				MainConnection.Close();
				sqlCommand.Dispose();
			}
		}

         /// <summary>
        /// update row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true for successfully updated</returns>
        public bool Update(Zd_BienBanKiemKe businessObject)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_Update]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
				sqlCommand.Parameters.Add(new SqlParameter("@KiemKe_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.KiemKe_ID));
				sqlCommand.Parameters.Add(new SqlParameter("@BoYTe", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.BoYTe));
				sqlCommand.Parameters.Add(new SqlParameter("@BenhVien", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.BenhVien));
				sqlCommand.Parameters.Add(new SqlParameter("@Khoa", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Khoa));
				sqlCommand.Parameters.Add(new SqlParameter("@MS", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.MS));
				sqlCommand.Parameters.Add(new SqlParameter("@So", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.So));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten1", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten1));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten2", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten2));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten3", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten3));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten4", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten4));
				sqlCommand.Parameters.Add(new SqlParameter("@Ten5", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Ten5));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh1", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh1));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh2", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh2));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh3", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh3));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh4", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh4));
				sqlCommand.Parameters.Add(new SqlParameter("@ChucDanh5", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChucDanh5));
				sqlCommand.Parameters.Add(new SqlParameter("@Date1", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Date1));
				sqlCommand.Parameters.Add(new SqlParameter("@Date2", SqlDbType.DateTime, 8, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Date2));
				sqlCommand.Parameters.Add(new SqlParameter("@ThoiGian", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ThoiGian));
				sqlCommand.Parameters.Add(new SqlParameter("@DeXuat", SqlDbType.NText, 1073741823, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.DeXuat));
				sqlCommand.Parameters.Add(new SqlParameter("@ThanhVien", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ThanhVien));
				sqlCommand.Parameters.Add(new SqlParameter("@ThuKy", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ThuKy));
				sqlCommand.Parameters.Add(new SqlParameter("@ChuTich", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.ChuTich));
				sqlCommand.Parameters.Add(new SqlParameter("@TinhTrang", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.TinhTrang));
				sqlCommand.Parameters.Add(new SqlParameter("@Field1", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field1));
				sqlCommand.Parameters.Add(new SqlParameter("@Field2", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field2));
				sqlCommand.Parameters.Add(new SqlParameter("@Field3", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field3));
				sqlCommand.Parameters.Add(new SqlParameter("@Field4", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field4));
				sqlCommand.Parameters.Add(new SqlParameter("@Field5", SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, businessObject.Field5));

                
                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("Zd_BienBanKiemKe::Update::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }

        /// <summary>
        /// Delete by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(Zd_BienBanKiemKeKeys keys)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_DeleteByPrimaryKey]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

				sqlCommand.Parameters.Add(new SqlParameter("@KiemKe_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.KiemKe_ID));


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();

                return true;
            }
            catch (Exception ex)
            {
                throw new Exception("Zd_BienBanKiemKe::DeleteByKey::Error occured.", ex);
            }
            finally
            {                
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Delete records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>true for successfully deleted</returns>
        public bool DeleteByField(string fieldName, object value)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_DeleteByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));
                
                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();

                return true;

            }
            catch (Exception ex)
            {                
                throw new Exception("Zd_BienBanKiemKe::DeleteByField::Error occured.", ex);
            }
            finally
            {             
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>Zd_BienBanKiemKe business object</returns>
        public Zd_BienBanKiemKe SelectByPrimaryKey(Zd_BienBanKiemKeKeys keys)
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_SelectByPrimaryKey]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

				sqlCommand.Parameters.Add(new SqlParameter("@KiemKe_ID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, keys.KiemKe_ID));

                
                MainConnection.Open();

                IDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    Zd_BienBanKiemKe businessObject = new Zd_BienBanKiemKe();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return businessObject;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Zd_BienBanKiemKe::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {             
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }


        /// <summary>
        /// Select all rescords
        /// </summary>
        /// <returns>list of Zd_BienBanKiemKe</returns>
        public List<Zd_BienBanKiemKe> SelectAll_List()
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_SelectAll]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
                MainConnection.Open();

                IDataReader dataReader = sqlCommand.ExecuteReader();

                return PopulateObjectsFromReader(dataReader);

            }
            catch (Exception ex)
            {                
                throw new Exception("Zd_BienBanKiemKe::SelectAll::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Select records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>list of Zd_BienBanKiemKe</returns>
        public List<Zd_BienBanKiemKe> SelectByField_List(string fieldName, object value)
        {

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_SelectByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));

                MainConnection.Open();
                
                IDataReader dataReader = sqlCommand.ExecuteReader();

                return PopulateObjectsFromReader(dataReader);

            }
            catch (Exception ex)
            {
                throw new Exception("Zd_BienBanKiemKe::SelectByField::Error occured.", ex);
            }
            finally
            {

                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

//thêm hiennv

        /// <summary>
        /// Select all rescords
        /// </summary>
        /// <returns>dataTable</returns>
        public DataTable SelectAll()
        {
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_SelectAll]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                
                MainConnection.Open();

                DataTable ds = new DataTable();
                SqlDataAdapter myadapter = new SqlDataAdapter(sqlCommand);
                myadapter.Fill(ds);

                return ds;

            }
            catch (Exception ex)
            {                
                throw new Exception("Zd_BienBanKiemKe::SelectAll::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }

        /// <summary>
        /// Select records by field
        /// </summary>
        /// <param name="fieldName">name of field</param>
        /// <param name="value">value of field</param>
        /// <returns>dataTable</returns>
        public DataTable SelectByField(string fieldName, object value)
        {

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "dbo.[zd_BienBanKiemKe_SelectByField]";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {

                sqlCommand.Parameters.Add(new SqlParameter("@FieldName", fieldName));
                sqlCommand.Parameters.Add(new SqlParameter("@Value", value));

                MainConnection.Open();
                
                DataTable ds = new DataTable();
                SqlDataAdapter myadapter = new SqlDataAdapter(sqlCommand);
                myadapter.Fill(ds);

                return ds;

            }
            catch (Exception ex)
            {
                throw new Exception("Zd_BienBanKiemKe::SelectByField::Error occured.", ex);
            }
            finally
            {

                MainConnection.Close();
                sqlCommand.Dispose();
            }

        }     
//end thêm hiennv
        #endregion

        #region Private Methods

        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(Zd_BienBanKiemKe businessObject, IDataReader dataReader)
        {


				businessObject.KiemKe_ID = dataReader.GetInt32(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.KiemKe_ID.ToString()));

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.BoYTe.ToString())))
				{
					businessObject.BoYTe = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.BoYTe.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.BenhVien.ToString())))
				{
					businessObject.BenhVien = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.BenhVien.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Khoa.ToString())))
				{
					businessObject.Khoa = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Khoa.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.MS.ToString())))
				{
					businessObject.MS = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.MS.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.So.ToString())))
				{
					businessObject.So = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.So.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten1.ToString())))
				{
					businessObject.Ten1 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten1.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten2.ToString())))
				{
					businessObject.Ten2 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten2.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten3.ToString())))
				{
					businessObject.Ten3 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten3.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten4.ToString())))
				{
					businessObject.Ten4 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten4.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten5.ToString())))
				{
					businessObject.Ten5 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Ten5.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh1.ToString())))
				{
					businessObject.ChucDanh1 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh1.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh2.ToString())))
				{
					businessObject.ChucDanh2 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh2.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh3.ToString())))
				{
					businessObject.ChucDanh3 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh3.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh4.ToString())))
				{
					businessObject.ChucDanh4 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh4.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh5.ToString())))
				{
					businessObject.ChucDanh5 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChucDanh5.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Date1.ToString())))
				{
					businessObject.Date1 = dataReader.GetDateTime(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Date1.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Date2.ToString())))
				{
					businessObject.Date2 = dataReader.GetDateTime(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Date2.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ThoiGian.ToString())))
				{
					businessObject.ThoiGian = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ThoiGian.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.DeXuat.ToString())))
				{
					businessObject.DeXuat = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.DeXuat.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ThanhVien.ToString())))
				{
					businessObject.ThanhVien = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ThanhVien.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ThuKy.ToString())))
				{
					businessObject.ThuKy = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ThuKy.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChuTich.ToString())))
				{
					businessObject.ChuTich = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.ChuTich.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.TinhTrang.ToString())))
				{
					businessObject.TinhTrang = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.TinhTrang.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field1.ToString())))
				{
					businessObject.Field1 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field1.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field2.ToString())))
				{
					businessObject.Field2 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field2.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field3.ToString())))
				{
					businessObject.Field3 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field3.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field4.ToString())))
				{
					businessObject.Field4 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field4.ToString()));
				}

				if (!dataReader.IsDBNull(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field5.ToString())))
				{
					businessObject.Field5 = dataReader.GetString(dataReader.GetOrdinal(Zd_BienBanKiemKe.Zd_BienBanKiemKeFields.Field5.ToString()));
				}


        }

        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of Zd_BienBanKiemKe</returns>
        internal List<Zd_BienBanKiemKe> PopulateObjectsFromReader(IDataReader dataReader)
        {

            List<Zd_BienBanKiemKe> list = new List<Zd_BienBanKiemKe>();

            while (dataReader.Read())
            {
                Zd_BienBanKiemKe businessObject = new Zd_BienBanKiemKe();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return list;

        }

        #endregion

	}
}
